package com.example.guiguihomemedical.controller;

import com.example.guiguihomemedical.common.Result;
import com.example.guiguihomemedical.entity.Fulfillment;
import com.example.guiguihomemedical.entity.Serviceitems;
import com.example.guiguihomemedical.entity.dto.FulfillmentAddData;
import com.example.guiguihomemedical.entity.dto.FulfillmentviewData;
import com.example.guiguihomemedical.service.FulfillmentService;
import com.example.guiguihomemedical.service.ServiceitemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("Fulfillment")
public class FulfillmentController {
    @Autowired
    private FulfillmentService fulfillmentService;
    @GetMapping
    public Result getFulfillmentList(){
        List<Fulfillment> FulfillmentList=fulfillmentService.findAllFulfillment();
        return Result.success(FulfillmentList);
    }
    @PostMapping
    public Result insertFulfillment(@RequestBody Fulfillment fulfillment){
        fulfillmentService.insertFulfillment(fulfillment);
        return Result.success();
    }

    @GetMapping("/Primary/{servicePackagesId}/{serviceItemId}/{idcard}")
    public Result findByPrimaryFulfillment(@PathVariable int servicePackagesId , @PathVariable int serviceItemId,@PathVariable String idcard){
        List<FulfillmentviewData> FulfillmentList=fulfillmentService.findByPrimaryFulfillment(servicePackagesId,serviceItemId,idcard);
        return Result.success(FulfillmentList);
    }

    @GetMapping("/PrimaryAdd/{servicePackagesId}/{serviceItemId}/{idcard}")
    public Result findByPrimaryFulfillmentAdd(@PathVariable int servicePackagesId , @PathVariable int serviceItemId,@PathVariable String idcard){
        FulfillmentAddData fulfillmentAddData = fulfillmentService.findByPrimaryFulfillmentAdd(servicePackagesId,serviceItemId,idcard);
        return Result.success(fulfillmentAddData);
    }
}
